package com.sxhuayuan.parking.controller.open.resp;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.alibaba.fastjson.annotation.JSONField;
import com.sxhuayuan.parking.entity.Order;
import com.sxhuayuan.parking.utils.DateUtils;
import com.sxhuayuan.parking.utils.SettingUtils;

import lombok.Getter;
import lombok.Setter;

/**
 * 查询车辆缴费记录结果
 * 
 * @author gy
 */
@Getter
@Setter
public class ParkCarOrdersResp {

	private String uniqueId;

	@JSONField(format = DateUtils.YYYYMMDDHHMMSS)
	private Date inTime;
	@JSONField(format = DateUtils.YYYYMMDDHHMMSS)
	private Date lastPayTime;

	private List<ParkOrder> orders;

	public void addOrders(List<Order> orderList) {
		if (orders == null) {
			orders = new ArrayList<ParkOrder>(orderList.size());
		}
		orderList.stream().forEach((order) -> {
			ParkOrder o = new ParkOrder();
			o.setTradeNo(order.getSn());
			o.setFee(SettingUtils.get().setScale(order.getMoney()).floatValue());
			o.setInTime(order.getEntertime());
			o.setStartTime(order.getStarttime());
			o.setEndTime(order.getEndtime());
			o.setPlatform(order.getPlatform().ordinal());
			o.setPayMethod(order.getMethod().ordinal());
			orders.add(o);
		});
	}
}
